<script>
    var items = <?= $items; ?>;
    var preview = <?= isset($_GET['preview']) ? 1 : 0; ?>;
</script>

<div id="hotels-placeholder">

    <div id="wrap" class="clearfix">

        <div id="aside">

            <div id="changeDetasilsBox"><? $this->load->view('hotels/parts/search_box') ?></div>

            <!-- Why? <div id="serchModule"><? $this->load->view('hotels/parts/search_box') ?></div> -->
            <? $this->load->view('destinations/parts/banner') ?>
            <? $this->load->view('hotels/parts/map_box') ?>

            <? $this->load->view('hotels/parts/filter') ?>

        </div><!-- / Aside -->

        <div id="main">

            <? $total_res = count($objects); ?>

            <div class="title title-search no-line">
                <p class="float-left"><?= lang('rentacar.results') ?>: <span id="cnt_results"><?= $total_res ?></span> </p>
                <h1><?= isset($_GET['dest_hot']) && trim($_GET['dest_hot']) != '' ? lang('search.search.results') : lang('search.search.results.clean') ?></h1>
            </div>

            <div class="search-list accomodation-list clearfix" id="results">
                <ul id="paging_cont">
                    <?
                        $i = 1;
                        $index_22 = 0;
                        if ($objects)
                            foreach ($objects as $hotel):

                                // Third page link
                                if (isset($session['check_in'])) {

                                    $link = base_url('hotels/details?hotel_id=' . $hotel->object_ID . '&amp;' . http_build_query($session, '', '&amp;'));
                                    $bt_title = lang('shared.book.now');
                                } else {

                                    $link = base_url('hotels/details_preview?hotel_id=' . $hotel->object_ID . '&amp;' . http_build_query($session, '', '&amp;'));
                                    $bt_title = lang('rentacar.details');
                                }
                                ?>

                                <li class="js_item car-box" id="box-<?= $hotel->object_ID ?>" style="display: block">
                                    <!--<div class="">-->



                                    <a href="<?= $link ?>"> 

                                        <? $thumbnail = $host_url . 'gallery/' . $hotel->photo_path . '/thumb_120x86/' . $hotel->photo_name; ?>

                                        <img src="<?= $thumbnail ?>" alt="<?= $hotel->object_name ?>" title="<?= $hotel->object_name ?>" /> 

                                    </a>
                                    <?
                                    if (isset($hotel->object_x_coordinate) && $hotel->object_x_coordinate != ""):
                                        if (isset($hotel->object_y_coordinate) && $hotel->object_y_coordinate != ""):
                                            ?>
                                            <span class="show_object_map">
                                                <a data-holder="<?= $index_22 ?>" title="<?= $hotel->object_name; ?>, <?= $hotel->destination_name; ?> - Show map" class="show_map_object" href="javascript:"> <?= lang('hotel.show_map_cap') ?></a>
                                            </span>
                                            <?
                                            $index_22++;
                                        endif;
                                        ?>
                                    <? endif; ?>
                                    <div class="details">

                                        <?
                                        if (isset($hotel->rooms[0]->selling_total)):

                                            $no_night = calculateDays($session['check_in'], $session['check_out']);
                                            ?>
                                            <div class="show_how_meny_nights"><?= lang('secure.price_for'); ?> <?= $no_night ?> <?
                                                if ($no_night == 1)
                                                    echo lang('secure.night');
                                                else
                                                    echo lang('secure.nights');
                                                ?>.</div>

                                        <? endif; ?>

                                        <div class="star-rating-box">

                                            <?
                                            if ($hotel->object_number_of_stars != "")
                                                $this->load->view('rentacar/parts/rating', array('no' => $i, 'score' => $hotel->object_number_of_stars));
                                            ?>

                                        </div>
                                        <?
                                        $pices = explode(" ", $hotel->object_name);
                                        ?>
                                        <h2><a href="<?= $link ?>"><span><?= $pices[0] ?></span><?
                                                for ($j = 1; $j <= count($pices) - 1; $j++) {
                                                    echo ' ' . $pices[$j];
                                                }
                                                ?></a>
                                        </h2>

                                        <p><?= clean_html($hotel->object_info) ?></p>

                                        <dl>

                                            <?
                                            $cnt_rooms = 1;
                                            if (isset($hotel->rooms) && count($hotel->rooms) > 0):
                                                foreach ($hotel->rooms as $room):
                                                    if ($cnt_rooms <= 2):
                                                        ?>

                                                        <dt><?= lang("room." . underscore($room->room_type_name)); ?></dt>
                                                        <dd class="one_room_list clearfix">

                                                            <span><?= isset($room->selling_total)?$room->selling_total.'&euro;':"" ?></span>

                                                            <div>
                                                                <div class="tooltip max_ps ps_<?= $room->room_max_person ?>" title="<B>Max Persons: <?= $room->room_max_person ?></b>"></div>
                                                            </div>

                                                        </dd>

                                                        <?
                                                        $cnt_rooms++;
                                                    endif;
                                                endforeach;
                                            endif;
                                            ?>

                                        </dl>

                                        <? if (isset($hotel->rooms[0]->selling_total)): ?>

                                            <span class='big'><?= $hotel->rooms[0]->selling_total; ?>€ <span>&nbsp;</span></span>
                                        <? endif; ?>

                                        <a href="<?= $link ?>" class="button"><?= $bt_title ?> &raquo;</a>

                                    </div>
                                </li> <!--/ Item -->

                                <?
                                $i++;
                            endforeach;
                    ?>

                </ul>
            </div><!-- / Three Columns -->


            <div class="two-columns clearfix">
                <? $this->load->view('parts/two_column') ?>
            </div>

        </div><!-- / Main -->


    </div><!-- / Wrap -->

</div>
<script type="text/javascript">
    var check_in = "<? if (isset($session['check_in'])) echo $session['check_in']; ?>";
    var check_out = "<? if (isset($session['check_out'])) echo $session['check_out']; ?>";
</script>

<div id="hide_content">
    <div id="google_box" style="">
        <div class="clearfix">

            <div id="google-list">

                <?
                    $index = 0;
                    if ($objects)
                        foreach ($objects as $object):
                            if (isset($object->object_x_coordinate) && $object->object_x_coordinate != ""):
                                if (isset($object->object_y_coordinate) && $object->object_y_coordinate != ""):

                                    $thumbnail = $host_url . 'gallery/' . $object->photo_path . '/thumb_130x130/' . $object->photo_name;
                                    ?>

                                    <div class="GH open-map-<?= $index ?>" data-holder="<?= $index ?>">
                                        <? $index++; ?>
                                        <img src="<?= $thumbnail ?>" alt="<?= $object->object_name; ?>" width="70" />

                                        <div class="title"><?= $object->object_name ?></div>
                                        <div class="subtitle"><?= $object->destination_name ?></div>

                                        <div class="stars">
                                            <?
                                            if ($object->object_number_of_stars != ""):


                                                $stars = (int) $object->object_number_of_stars;

                                                for ($i = 0; $i < $stars; $i++):
                                                    ?>
                                                    <div class="GH-star"></div>
                                                    <?
                                                endfor;
                                            endif;
                                            ?>
                                        </div>


                                        <div class="list"></div>

                                        <?
                                        if (isset($object->rooms) && count($object->rooms) > 0) {
                                            ?>
                                            <div class="price"><?= $object->rooms[0]->selling_total ?>&euro;</div>


                                            <?
                                        } else {
                                            ?>
                                            <div class="no-price">Price is unknown</div>
                                        <? } ?>
                                        <div></div>

                                    </div>

                                    <?
                                endif;
                            endif;
                        endforeach;
                ?>


            </div>

            <div id="google_map">
                <div id="map_canvas" style="width:100%; height:100%"></div>
            </div>

        </div>

    </div>
</div>
<script type="text/javascript">

    var LOADMAP = true;

<? if ($index == 0): ?>
            LOADMAP = false;
    <? endif; ?>
</script>

<? if ($index == 0): ?>
        <style>
            #google_box{
                width: 0;
                height: 0;
                overflow: hidden
            }
        </style>
    <? endif; ?>